﻿Public Class settings
    Dim myFrm As Form1
    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Hide()
    End Sub
    Public Sub setForm(ByVal frm As Form1)
        myFrm = frm
    End Sub

    Private Sub settings_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txtLogIn.Text = My.Settings("loginname").ToString
        txtSendAs.Text = My.Settings("emailfrom").ToString
        txtserver.Text = My.Settings("smtpserver").ToString
        txtPassword.Text = My.Settings("password").ToString

        chkSSL.Checked = My.Settings("ssl")

        Select Case My.Settings("interval")
            '24 Hours
            '12 Hours
            '6 Hours
            '1 Hour
            '30 Minutes
            Case (3600000 * 24)
                cbInterval.SelectedText = "24 Hours"
            Case (3600000 * 12)
                cbInterval.SelectedText = "12 Hours"
            Case (3600000 * 6)
                cbInterval.SelectedText = "6 Hours"
            Case 3600000
                cbInterval.SelectedText = "1 Hour"
            Case 1800000
                cbInterval.SelectedText = "30 Minutes"
            Case Else
                cbInterval.SelectedText = "1 Hour"
        End Select


    End Sub

    Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
        My.Settings("loginname") = txtLogIn.Text
        My.Settings("emailfrom") = txtSendAs.Text
        My.Settings("smtpserver") = txtserver.Text
        My.Settings("password") = txtPassword.Text
        My.Settings("ssl") = chkSSL.Checked
        My.Settings.Save()


        Select Case cbInterval.Text
            '24 Hours
            '12 Hours
            '6 Hours
            '1 Hour
            '30 Minutes
            Case "24 Hours"
                My.Settings("interval") = (3600000 * 24)
                myFrm.Timer1.Interval = (3600000 * 24)
            Case "12 Hours"
                My.Settings("interval") = (3600000 * 12)
                myFrm.Timer1.Interval = (3600000 * 12)
            Case "6 Hours"
                My.Settings("interval") = (3600000 * 6)
                myFrm.Timer1.Interval = (3600000 * 6)
            Case "1 Hour"
                My.Settings("interval") = 3600000
                myFrm.Timer1.Interval = 3600000
            Case "30 Minutes"
                My.Settings("interval") = 1800000
                myFrm.Timer1.Interval = 1800000
            Case Else
                My.Settings("interval") = 3600000
                myFrm.Timer1.Interval = 3600000
        End Select

        Me.Hide()

    End Sub
End Class